#pragma once
#include <Engine/SmartPtr.h>
#include <Engine/Renderer/RendererEnums.h>
#include <Engine/Renderer/RendererStructs.h>
#include <Engine/Misc/ColorRamp.h>

namespace fastbird
{
	class Vec4;
	class IMaterial : public ReferenceCounter
	{
	public:
		static IMaterial* CreateMaterial();
		static IMaterial* CreateMaterial(const char* filepath);
		static void ReloadMaterial(const char* name);

		virtual ~IMaterial(){}

		virtual bool LoadFromFile(const char* filepath) = 0;
		virtual const char* GetName() const = 0;

		virtual void SetAmbientColor(float r, float g, float b, float a) = 0;
		virtual void SetAmbientColor(const Vec4& ambient) = 0;
		virtual void SetDiffuseColor(float r, float g, float b, float a) = 0;
		virtual void SetDiffuseColor(const Vec4& diffuse) = 0;
		virtual void SetSpecularColor(float r, float g, float b, float shine) = 0;
		virtual void SetSpecularColor(const Vec4& specular) = 0;
		virtual void SetEmissiveColor(float r, float g, float b, float strength) = 0;
		virtual void SetEmissiveColor(const Vec4& emissive) = 0;

		virtual void SetTexture(const char* filepath, int slot, BINDING_SHADER shader, const SAMPLER_DESC& samplerDesc, 
			TEXTURE_TYPE type=TEXTURE_TYPE_DEFAULT, ColorRamp& cr=ColorRamp()) = 0;
		virtual ColorRamp& GetColorRamp(int slot, BINDING_SHADER shader) = 0;
		virtual void RefreshColorRampTexture(int slot, BINDING_SHADER shader) = 0;

		virtual void SetShaderFile(const char* shaderFile) = 0;
		virtual void SetCompileParameters(const char* cps) = 0;
		virtual void SetMaterialParameters(unsigned index, const Vec4& value) = 0;


		virtual const Vec4& GetAmbientColor() const = 0;
		virtual const Vec4& GetDiffuseColor() const = 0;
		virtual const Vec4& GetSpecularColor() const = 0;
		virtual const Vec4& GetEmissiveColor() const = 0;

		virtual const char* GetShaderFile() const = 0;
		virtual void* GetShaderByteCode(unsigned& size) const = 0;
		virtual const char* GetCompileParameters() const = 0;
		virtual const Vec4& GetMaterialParameters(unsigned index) const = 0;

		virtual void Bind() = 0;
		virtual void RegisterReloading() = 0;
	};
}